#include "dindexes.h"
#include "ui_dindexes.h"


dIndexes *dIndexes::instance = NULL;


dIndexes * dIndexes::getInstance() {
    if(instance == NULL){
        instance = new dIndexes();
    }
    return instance;
}

dIndexes::dIndexes(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::dIndexes)
{
    ui->setupUi(this);
    QStringList fonts;
    fonts << "IAE" << "ISE" << "ITAE" << "ITSE" << "Var Y" << "Var SC";
    ui->tableWidget->setHorizontalHeaderLabels(fonts);
}

dIndexes::~dIndexes()
{
    instance = NULL;
    delete ui;
}

void dIndexes::InsertRow(double indexes[6]){
    QTableWidgetItem *itens[6];
    int row = ui->tableWidget->rowCount();
    ui->tableWidget->insertRow(row);
    for(int i = 0; i < 6; i++){
        itens[i] = new QTableWidgetItem(tr("%1").arg(indexes[i]));
        itens[i]->setFlags(Qt::ItemIsSelectable);
        ui->tableWidget->setItem(row, i, itens[i]);
    }

}

void dIndexes::changeEvent(QEvent *e)
{
    QDialog::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}
